from django.shortcuts import render
from rest_framework.response import Response
from home import models,homeser
from rest_framework.views import APIView
# Create your views here.

class HeadNav(APIView):
    def get(self,request):
        #展示头部导航有效的数据 按照order排序
        navlist = models.Nav.objects.filter(position=0,flag=True).order_by("order")
        ser = homeser.NavSerializer(navlist,many=True)
        return Response({"code":200,"msg":"ok","data":ser.data})

class FootNav(APIView):
    def get(self,request):
        #展示尾部导航有效的数据 按照order排序
        navlist = models.Nav.objects.filter(position=1,flag=True).order_by("order")
        ser = homeser.NavSerializer(navlist,many=True)
        return Response({"code":200,"msg":"ok","data":ser.data})
